Skip to main content

Get Historical Rate

Query historical exchange rates by date for a foreign currency against VND. Each date returns the closing rate (end-of-day rate) for both SELL and BUY directions, supporting reconciliation and analysis.

Workflow

Endpoint

  • URL: /api/v1/fx/historical-rate
  • Method: POST

Request

ParameterData TypeRequiredDescription
request_idstring(50)YesSee section 3 Introduction
request_timestring(19)YesSee section 3 Introduction
merchant_codestring(20)YesSee section 3 Introduction
currencystring(3)YesForeign currency to query (paired against VND), e.g., USD
from_datestring(10)YesQuery start date (inclusive), format YYYY-MM-DD
to_datestring(10)YesQuery end date (inclusive), format YYYY-MM-DD. Constraint: to_date ≥ from_date, query span max 30 days, to_date not greater than today.

Example Request

{
"request_id": "MERCHANT1234BK202606050004",
"request_time": "2026-06-05 10:16:30",
"merchant_code": "MERCHANT1234",
"currency": "USD",
"from_date": "2026-06-01",
"to_date": "2026-06-04"
}

Response

ParameterData TypeRequiredDescription
response_codeint(4)YesResult code
response_messagestring(200)YesResult code description
merchant_codestring(20)YesMerchant code
currency_pairstring(10)YesStandardized currency pair, e.g., USD/VND
dataArray of ObjectsYesList of rates by date, sorted ascending. Dates without data do not appear.

Data Array Structure

ParameterData TypeDescription
datestring(10)Date of the rate, format YYYY-MM-DD
sell_ratedecimal(18,4)End-of-day closing rate for SELL direction (Merchant sells foreign currency, receives VND)
buy_ratedecimal(18,4)End-of-day closing rate for BUY direction (Merchant uses VND to buy foreign currency)

Example Response

{
"response_code": 200,
"response_message": "Success",
"merchant_code": "MERCHANT1234",
"currency_pair": "USD/VND",
"data": [
{ "date": "2026-06-01", "sell_rate": 26430.0000, "buy_rate": 26495.0000 },
{ "date": "2026-06-02", "sell_rate": 26440.0000, "buy_rate": 26500.0000 },
{ "date": "2026-06-03", "sell_rate": 26445.0000, "buy_rate": 26505.0000 },
{ "date": "2026-06-04", "sell_rate": 26450.0000, "buy_rate": 26510.0000 }
]
}

Error Codes

Response CodeResponse MessageDescription
200Success
101System ErrorUnexpected error on Baokim's side
110Invalid Merchant Codemerchant_code is undefined
120Invalid SignatureHeader Signature is invalid
404Currency Not SupportedRequested foreign currency is not in Merchant's configuration
416Invalid Date Rangeto_date < from_date, span > 30 days, or to_date > today
422Validation ErrorRequest field is missing or invalid
429Too Many RequestsExceeded rate limit for Merchant